package com.hd.util;

import net.coobird.thumbnailator.Thumbnails;

import java.io.IOException;

/**
 * 缩放图片
 */
public class ThumbnailsUtil {
    public static void thumbnail(String sourcePath,float scale,String targetPath){
        try{
            Thumbnails.of(sourcePath).scale(0.2f).toFile(targetPath);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    public static void main(String[] args)throws IOException{
        //按照比例进行缩小和放大
        String fromPic="C:\\Users\\Administrator\\Pictures\\Saved Pictures\\图片1.jpg";
        String toPic="D:\\12.png";
        Thumbnails.of(fromPic).scale(0.2f).toFile(toPic);//按比例缩小
    }
}
